#pragma once
#include "AnyEditor.h"
#include "ShapeReps.h"
#include "RenderEngine.h"

class GEOMDBAPI CEditorHelper :
	public CAnyEditor
{
public:
	CEditorHelper(void);
	virtual ~CEditorHelper(void);
	virtual void Initialize(CAnyView* pView);

	virtual EditorState Start(void);
	virtual void Finish(void);

	void SetStep(UINT nStep){m_nStep = nStep;}
	UINT GetStep(){return m_nStep;}
protected:
	bool CreateLine(const gp_Pnt& ptStart, const gp_Pnt& ptEnd, 
		TopoDS_Shape& shape);

	void Render(CShapeReps& shapeRep, bool bUpdate);

	CSelectionSet& Selecter();

	CSelectionSet* m_pSelectionSet;
protected:
	// display temporary
	CShapeReps m_ShapeRep;
	int m_nStep;
};

//////////////////////////////////////////////////////////////////////////
class GEOMDBAPI CPointCapture :
	public CEditorHelper
{
public:
	CPointCapture(gp_Pnt& refPoint);
	~CPointCapture(void);
	virtual EditorState OnLButtonDown(UINT nFlags, long x, long y);
	virtual EditorState OnLButtonUp(UINT nFlags, long x, long y);
	virtual void OnMouseMove(UINT nFlags, long x, long y);

protected:
	gp_Pnt&	m_refPoint;
};


//////////////////////////////////////////////////////////////////////////

class GEOMDBAPI CLengthCapture :
	public CEditorHelper
{
public:
	CLengthCapture(const gp_Pnt& refStart,
		gp_Pnt& refEnd,
		Standard_Real& refLength);

	~CLengthCapture(void);
	virtual EditorState OnLButtonDown(UINT nFlags, long x, long y);
	virtual EditorState OnLButtonUp(UINT nFlags, long x, long y);
	virtual void OnMouseMove(UINT nFlags, long x, long y);

protected:
	const gp_Pnt& m_refStart;
	gp_Pnt& m_refEnd;
	Standard_Real& m_refLength;
};
//////////////////////////////////////////////////////////////////////////

class GEOMDBAPI CRectCapture :
	public CEditorHelper
{
public:
	CRectCapture(const gp_Pnt& refStart,
		gp_Pnt& refEnd,
		Standard_Real& refLength,
		Standard_Real& refWidth);

	~CRectCapture(void);
	virtual EditorState OnLButtonDown(UINT nFlags, long x, long y);
	virtual EditorState OnLButtonUp(UINT nFlags, long x, long y);
	virtual void OnMouseMove(UINT nFlags, long x, long y);

protected:
	const gp_Pnt& m_refStart;
	gp_Pnt& m_refEnd;
	Standard_Real& m_refLength;
	Standard_Real& m_refWidth;
};
//////////////////////////////////////////////////////////////////////////

class GEOMDBAPI CHeightCapture :
	public CEditorHelper
{
public:
	CHeightCapture(const gp_Pnt& refStart,
		gp_Pnt& refEnd,
		Standard_Real& refHeight);

	~CHeightCapture(void);
	virtual EditorState OnLButtonDown(UINT nFlags, long x, long y);
	virtual EditorState OnLButtonUp(UINT nFlags, long x, long y);
	virtual void OnMouseMove(UINT nFlags, long x, long y);

protected:
	const gp_Pnt& m_refStart;
	gp_Pnt& m_refEnd;
	Standard_Real& m_refHeight;
};

//////////////////////////////////////////////////////////////////////////

class GEOMDBAPI CAngleCapture :
	public CEditorHelper
{
public:
	CAngleCapture(const gp_Pnt& refCenter,
		const gp_Pnt& refStart,
		const gp_Dir& refPlaneNormal,
		gp_Pnt& refEnd,
		Standard_Real& refAngle);

	~CAngleCapture(void);
	virtual EditorState OnLButtonDown(UINT nFlags, long x, long y);
	virtual EditorState OnLButtonUp(UINT nFlags, long x, long y);
	virtual void OnMouseMove(UINT nFlags, long x, long y);
protected:
	void ComputeAngle(long x, long y);

protected:
	const gp_Pnt& m_refCenter;
	const gp_Pnt& m_refStart;
	const gp_Dir& m_refPlaneNormal;
	gp_Pnt& m_refEnd;
	Standard_Real& m_refAngle;

	CShapeReps m_lineStart;
	CShapeReps m_lineEnd;
};

//////////////////////////////////////////////////////////////////////////
class CSelectionSet;

class GEOMDBAPI CShapeCapture :
	public CEditorHelper
{
public:
	CShapeCapture(TopAbs_ShapeEnum nShapeType, 
		TopoDS_Shape& shape,
		gp_Pnt& refCapturePt);

	~CShapeCapture(void);
	virtual EditorState OnLButtonDown(UINT nFlags, long x, long y);
	virtual EditorState OnLButtonUp(UINT nFlags, long x, long y);
	virtual void OnMouseMove(UINT nFlags, long x, long y);

	virtual void Initialize(CAnyView* pView);
protected:
	TopAbs_ShapeEnum m_nShapeType;
	TopoDS_Shape& m_Shape;
	gp_Pnt& m_refPoint;
};